﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Mail;
using SchoolProject2012.Langue;

namespace SchoolProject2012.Functions
{
    public class Mail
    {
        public static void sendMail(string subject, string from, List<string> to, string message)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress(from);
                foreach (string adresse in to)
                {
                    mail.To.Add(adresse);
                }
                mail.Subject = subject;
                mail.Body = message;
                mail.IsBodyHtml = false;
                SmtpClient smtp = new SmtpClient("smtp.live.com");
                smtp.Credentials = new NetworkCredential("schoolproject2012@live.fr", "azerty2012erp");
                smtp.Port = 25;
                smtp.EnableSsl = true;

                smtp.SendAsync(mail, "test");
            }
            //smtp.Send(mail);
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        public static string messagePassword(string email)
        {
            string message = "Hello,\r\n\r\nYou have requested a password. If you want a new password thank you for this link.\r\n\r\nhttp://77.204.27.145/Shared/log/confirmPassword/" + email + " .\r\n\r\nA new email will be sent with your new password";
            return message;
        }

        public static string messageConfirmPassword(string password)
        {
            string message = "Hello,\r\n\r\nFollowing your request to change the password, here's the new:.\r\n\r\n" + password;
            return message;
        }
    }
}